﻿using System;
using System.Collections.Generic;
using System.Text;

using Torch.WL.Entity.CleanChina;
using System.Data.SqlClient;
using System.Data;

namespace Torch.WL.DataAccess.CleanChina
{
    public class TbPersonAccess
    {
        public TbPersonAccess()
        {

        }


        public int Add(TbPersonEntity model)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@personId", SqlDbType.Int,4),
					new SqlParameter("@personName", SqlDbType.VarChar,50),
					new SqlParameter("@workCompany", SqlDbType.VarChar,200),
					new SqlParameter("@address", SqlDbType.VarChar,300),
					new SqlParameter("@province", SqlDbType.VarChar,50),
					new SqlParameter("@city", SqlDbType.VarChar,50),
					new SqlParameter("@mobile", SqlDbType.VarChar,15),
					new SqlParameter("@email", SqlDbType.VarChar,50)};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = model.personName;
            parameters[2].Value = model.workCompany;
            parameters[3].Value = model.address;
            parameters[4].Value = model.province;
            parameters[5].Value = model.city;
            parameters[6].Value = model.mobile;
            parameters[7].Value = model.email;

            DbHelperSQL.RunProcedure("twsp_Person_ADD", parameters, out rowsAffected);
            return (int)parameters[0].Value;
        }



    }
}
